<?php

class forgetpasswordForm extends UserForm
{

    public function configure()
    {
        parent::configure();
        // i18n
        $i18n = $this->getOption('i18n');
        // username input text
        $this->getWidgetSchema()->setHelp('username', $i18n->__('Please type your username'));
        $this->useFields('password','re_password');
        $this->widgetSchema->setNameFormat('forget[%s]');
    }

}

//class forgetpasswordForm extends sfForm {
//
//    public function configure() {
//        // i18n
//        $i18 = sfContext::getInstance()->getI18N();
//        // username input text
//        $this->setWidget('username', new sfWidgetFormInputText(array('label' => 'enter username or email ')));
//        // username validator email or username - required
//        $this->setValidator('username', new sfValidatorOr(array(
//                    new sfValidatorRegex(array('pattern' => '/^(?=.*[a-zA-Z\d]).{4,15}$/', 'min_length' => 4, 'max_length' => 15)),
//                    new sfValidatorRegex(array('pattern' => '/^[a-z][a-z0-9_.-]*@[a-z0-9.-]+[.][a-z]{2,}$/ii', 'min_length' => 5, 'max_length' => 255, 'required' => true))),
//                        array('required' => true),
//                        array('invalid' => $i18->__('Please enter a valid username or email.'), 'required' => $i18->__('Required field, Please type your username or emial.'))));
//        // username help message
//        $this->getWidgetSchema()->setHelp('username', $i18->__('Please type your username/email.'));
//        /*
//         * post validator to check $user exist within the same company 
//         */
//        $this->validatorSchema->setPostValidator(
//                new sfValidatorCallback(array('callback' => array($this, 'postValidator')))
//        );
//        $this->widgetSchema->setNameFormat('forget[%s]');
//    }
//
//    /**
//     * post validator to check $user exist within the same company 
//     * @param Array $validator
//     * @param Array $values
//     * @return Array 
//     */
//    public function postValidator($validator, $values) {
//        $i18 = sfContext::getInstance()->getI18N();
//        $error = array();
//        //check user exist (email or username)
//        $user = UserTable::getInstance()->checkUserExist($values['username'], $this->getOption('slug'));
//
//        if (!$user) {
//            // add error 
//            $error['username'] = new sfValidatorError($validator, $i18->__('This User not exist.') . '!');
//        }
//        // throw error
//        throw new sfValidatorErrorSchema($validator, $error);
//        // return values
//        return $values;
//    }
//
//}
